package com.caigou.controller;

import com.caigou.annotation.OperLog;
import com.caigou.bean.cms.param.SurveyCatalogParam;
import com.caigou.bean.exam.entity.Users;
import com.caigou.constant.NewsConstant;
import com.caigou.security.utils.CurrentUser;
import com.caigou.service.SurveyCatalogService;
import com.caigou.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/surveyCatalog/")
public class SurveyCatalogController {

    @Resource
    private SurveyCatalogService surveyCatalogService;

    @ApiOperation("获取目录管理页列表数据")
    @RequestMapping("loadSurveyCatalogConfigList")
    public Result loadSurveyCatalogConfigList(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.loadSurveyCatalogConfigList(param);
    }

    @ApiOperation("更新表单目录配置数据的发布状态")
    @RequestMapping("updateSurveyCatalogConfigStatus")
    @OperLog(operModule = NewsConstant.FORM_MODULE, operType = NewsConstant.UPDATE_OPERATION, operDesc = "禁用目录页")
    public Result updateSurveyCatalogConfigStatus(@RequestBody SurveyCatalogParam param, @CurrentUser Users users){
        return surveyCatalogService.updateSurveyCatalogConfigStatus(param,users);
    }

    @ApiOperation("删除表单目录数据(状态删除)")
    @RequestMapping("deleteSurveyCatalogConfig")
    @OperLog(operModule = NewsConstant.FORM_MODULE, operType = NewsConstant.DELETE_OPERATION, operDesc = "删除目录页")
    public Result deleteSurveyCatalogConfig(@RequestBody SurveyCatalogParam param, @CurrentUser Users users){
        return surveyCatalogService.deleteSurveyCatalogConfig(param,users);
    }

    @ApiOperation("保存表单目录配置数据")
    @RequestMapping("saveSurveyCatalogConfig")
    @OperLog(operModule = NewsConstant.FORM_MODULE, operType = NewsConstant.ADD_OPERATION, operDesc = "创建目录页")
    public Result saveSurveyCatalogConfig(@RequestBody SurveyCatalogParam param, @CurrentUser Users users){
        return surveyCatalogService.saveSurveyCatalogConfig(param,users);
    }

    @ApiOperation("获取目录修改页数据")
    @RequestMapping("loadSurveyCatalogConfigData")
    public Result loadSurveyCatalogConfigData(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.loadSurveyCatalogConfigData(param);
    }

    @ApiOperation("更新目录页数据")
    @RequestMapping("updateSurveyCatalogConfigData")
    @OperLog(operModule = NewsConstant.FORM_MODULE, operType = NewsConstant.UPDATE_OPERATION, operDesc = "修改目录页/修改目录页设置")
    public Result updateSurveyCatalogConfigData(@RequestBody SurveyCatalogParam param, @CurrentUser Users users){
        return surveyCatalogService.updateSurveyCatalogConfigData(param,users);
    }

    @ApiOperation("获取智能表单版本回收站数据")
    @RequestMapping("loadSurveyRecycledList")
    public Result loadSurveyRecycledList(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.loadSurveyRecycledList(param);
    }

    @ApiOperation("删除目录页数据(物理删除)")
    @RequestMapping("deleteSurveyCatalogConfigData")
    @OperLog(operModule = NewsConstant.FORM_MODULE, operType = NewsConstant.DELETE_OPERATION, operDesc = "永久删除目录页")
    public Result deleteSurveyCatalogConfigData(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.deleteSurveyCatalogConfigData(param);
    }

    @ApiOperation("恢复集合页数据")
    @RequestMapping("updateRecoverCatalogConfig")
    @OperLog(operModule = NewsConstant.FORM_MODULE, operType = NewsConstant.UPDATE_OPERATION, operDesc = "恢复目录页")
    public Result updateRecoverCatalogConfig(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.updateRecoverCatalogConfig(param);
    }

    @ApiOperation("清空回收站数据(目录)")
    @RequestMapping("cleanSurveyCatalogRecycled")
    public Result cleanSurveyCatalogRecycled(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.cleanSurveyCatalogRecycled(param);
    }

    @ApiOperation("获取历史记录(表单+目录)")
    @RequestMapping("loadSurveyHistoryList")
    public Result loadSurveyHistoryList(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.loadSurveyHistoryList(param);
    }

    @ApiOperation("获取目录统计页面数据")
    @RequestMapping("loadSurveyCatalogStatistics")
    public Result loadSurveyCatalogStatistics(@RequestBody SurveyCatalogParam param){
        return surveyCatalogService.loadSurveyCatalogStatistics(param);
    }
}
